< previous page page_377 next page >

Page 377
0377-01.gif
Figure 12.5
Defining a world window using a picture box's scale properties.
to map the viewport to a world window with corners at (0, 10) and (10, 0). Finally, the viewport's Paint event handler calls subroutine DrawSmiley to draw a smiley face centered on the point (5, 5) in world coordinates.
You can modify this program to experiment with different viewport and world window parameters. For example, try changing the world window corners to (-10, 20) and (20, -10) using the following statements.
e10a6a0a59f035e870d90cca05b85fce.gif
picViewport.ScaleLeft = 10
picViewport.ScaleTop = 20
picViewport.ScaleWidth = (20  10)
picViewport.ScaleHeight = (10  20)
Practice changing the viewport and world window parameters until you get a feel for how you can use them to pan, zoom, and stretch the image.
Zooming and Panning in Visual Basic
Using picture boxes together with world windows and viewports, you can easily write programs that magnify and pan across a picture. If you attach these techniques to menus and scrollbars, you can build a sophisticated drawing system with surprisingly little effort.
Zooming In
To zoom in on a picture, let the user select a new magnification level using one of the three methods described earlier:

 
< previous page page_377 next page >